package com.labichaoka.chaoka.ui.baseinfo.person;

import android.content.Context;
import android.graphics.Typeface;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.labichaoka.chaoka.R;
import com.labichaoka.chaoka.base.GlobalParams;
import com.labichaoka.chaoka.entity.KuResponse;

import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by ruan on 2018/7/26.
 */

public class PersonInfoAdapter extends RecyclerView.Adapter<PersonInfoAdapter.MyViewHolder>{
    private Typeface iconfont;
    private List<GlobalParams.Education> list;
    private LayoutInflater layoutInflater;

    public PersonInfoAdapter(Context context, List<GlobalParams.Education> data) {
        iconfont= Typeface.createFromAsset(context.getAssets(), "iconfont/iconfont.ttf");
        this.list=data;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_person_info_list, parent, false);
        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.tv.setText(list.get(position).getValue());

        if (mListener!=null){
            holder.layout.setOnClickListener((view)->{
                mListener.onItemClick(position);
            });
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends  RecyclerView.ViewHolder{
        @BindView(R.id.name)
                TextView tv;
        @BindView(R.id.layout)
        LinearLayout layout;
        MyViewHolder(View itemView){
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

    public interface OnItemClickListener{
        void onItemClick(int position);
    }

    public OnItemClickListener mListener;

    public void setOnItemClickListener(OnItemClickListener listener){
        this.mListener=listener;
    }
}



